<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use Illuminate\Support\Facades\Input;
use App\Msgs;
use App\Http\Requests;

class MsgsController extends Controller
{
    public function save(Request $request)
    {

        $msg = new Msgs();
        $now = time();
        $msg->name = Input::get("name");
        $msg->phone = Input::get("phone");
        $msg->wechatId = Input::get("wechatId");
        $msg->content = Input::get("content");
        $msg->created = $now;
        $msg->updated = $now;

        $data = array();
        if ($msg->save()){
            $data['code'] = 1001;
            $data['msg'] = '操作成功';
            echo json_encode($data);
            exit;
        } else {
            $data['code'] = 1002;
            $data['msg']  = '操作失败';
            echo json_encode($data);
            exit;
        }
    }
}
